*************************************************************************************************
*																								*
*						Careers - Cohort-specific regressions, 2-year intervals					*
*						name file: regression_cohort_2yr.do										*
*																								*
*************************************************************************************************


*************************************************************************************************
*										Preamble												*
*************************************************************************************************



* ---> Michael For convenience, rename & label variables here
rename bipman_ev BD
rename bdsib_ev BDSIB
rename depr_ev DEPR
rename schizo_ev SCHIZO
rename anxiety_ev ANX // defined as "ever anxiety diagnosis"
rename earnings EARN
rename totalincome INC
rename disab DISAB
rename female FEMALE
rename birthcohort BIRTHCOHORT
rename year YEAR
rename momid MOMID
rename college COLLEGE // NOTE: This should be a variable equal to one for all people who have at least a college degree
rename highschool HS // NOTE: This should be a variable equal to one for all people who have at least a HS degree
gen MENTAL = DEPR == 1 | SCHIZO == 1 | BD == 1 | ANX == 1 // Note: added BD and anxiety
replace MENTAL = . if DEPR == . | SCHIZO == . | BD == . | ANX == .

label var MENTAL 	"MH condition"
label var BD 		"BD"
label var BDSIB 	"BD sibling"
label var DEPR 		"Depression"
label var SCHIZO 	"Schizophrenia"
label var ANX 		"Anxiety"

* "fix" or create some variables
gen LNEARN = ln(EARN)
replace LNEARN = 0 if LNEARN == .
gen NOEARN = EARN == 0
gen POSEARN = NOEARN == 0
gen LNINC = ln(INC) 
replace LNINC = 0 if LNINC == .
gen NOINC = INC == 0
gen POSINC = NOINC == 0
gen FEMALE_BD_POST = FEMALE * BD * POST

* ---> Cohort coefficients
global xvar = "BD DEPR SCHIZO ANX FEMALE c.FEMALE#i.YEAR c.FEMALE#i.BIRTHCOHORT"
local xvar_pose = "c.BD#c.NOEARN c.DEPR#c.NOEARN c.SCHIZO#c.NOEARN c.ANX#c.NOEARN c.FEMALE#c.NOEARN c.BD_POST#c.NOEARN"
local xvar_posi = "c.BD#c.NOINC c.DEPR#c.NOINC c.SCHIZO#c.NOINC c.ANX#c.NOINC c.FEMALE#c.NOINC c.BD_POST#c.NOINC"

global BDcoef1 = ""
global Mcoef1 = ""
global Dcoef1 = ""
global Scoef1 = ""

global BDcoef2 = ""
global Mcoef2 = ""
global Dcoef2 = ""
global Scoef2 = ""

gen BIRTHCOHORT2 = .

forvalues y = 1940(2)1952 {
local z = `y' + 1
replace BIRTHCOHORT2 = `y' if (BIRTHCOHORT == `y' | BIRTHCOHORT ==  `z')
gen BD_`y' = BD * (BIRTHCOHORT == `y' | BIRTHCOHORT == `z')
gen MENTAL_`y' = MENTAL * (BIRTHCOHORT == `y' | BIRTHCOHORT == `z')
gen DEPRANX_`y' = DEPRANX * (BIRTHCOHORT == `y' | BIRTHCOHORT == `z')
gen SCHIZO_`y' = SCHIZO * (BIRTHCOHORT == `y' | BIRTHCOHORT == `z')
label var  BD_`y' "`y'"
global BDcoef1 = "$BDcoef1 BD_`y'"
global Mcoef1 =  "$Mcoef1 MENTAL_`y'"
global Dcoef1 =  "$Dcoef1 DEPRANX_`y'"
global Scoef1 =  "$Scoef1 SCHIZO_`y'"
}
forvalues y = 1956(2)1978 {
local z = `y' + 1
replace BIRTHCOHORT2 = `y' if (BIRTHCOHORT == `y' | BIRTHCOHORT ==  `z')
gen BD_`y' = BD * (BIRTHCOHORT == `y' | BIRTHCOHORT == `z')
gen MENTAL_`y' = MENTAL * (BIRTHCOHORT == `y' | BIRTHCOHORT == `z')
gen DEPRANX_`y' = DEPRANX * (BIRTHCOHORT == `y' | BIRTHCOHORT == `z')
gen SCHIZO_`y' = SCHIZO * (BIRTHCOHORT == `y' | BIRTHCOHORT == `z')
label var  BD_`y' "`y'"
global BDcoef2 = "$BDcoef1 BD_`y'"
global Mcoef2 =  "$Mcoef1 MENTAL_`y'"
}

tempvar zero
gen `zero' = 0
label var `zero' "0"
tempvar zero
gen `zero' = 0
label var `zero' "0"


*************************************************************************************************
*										Regressions												*
*************************************************************************************************

*---> DiD, for BD and Mental

* BD
areg NOEARN BD DEPRANX SCHIZO  $BDcoef1 `zero' $BDcoef2 FEMALE c.FEMALE#i.YEAR i.YEAR i.BIRTHCOHORT2 if BIRTHCOHORT >= 1950, a(MOMID) cluster(MOMID)
areg LNEARN BD DEPRANX SCHIZO $BDcoef1 `zero' $BDcoef2 FEMALE c.FEMALE#i.YEAR i.YEAR i.BIRTHCOHORT2 if NOEARN == 0 & BIRTHCOHORT >= 1950, a(MOMID) cluster(MOMID)

*---> Triple Diff
areg NOEARN BD MENTAL $BDcoef1 `zero' $BDcoef2 $Mcoef1 $Mcoef2 FEMALE c.FEMALE#i.YEAR i.YEAR i.BIRTHCOHORT2 if BIRTHCOHORT >= 1950, a(MOMID) cluster(MOMID) 
areg LNEARN BD MENTAL $BDcoef1 `zero' $BDcoef2 $Mcoef1 $Mcoef2 FEMALE c.FEMALE#i.YEAR i.YEAR i.BIRTHCOHORT2 if NOEARN == 0 & BIRTHCOHORT >= 1950, a(MOMID) cluster(MOMID) 


* Condition by condition (appendix)
areg NOEARN BD DEPRANX SCHIZO   $BDcoef1 `zero' $BDcoef2 $Dcoef1 $Dcoef2 $Scoef1 $Scoef2 FEMALE c.FEMALE#i.YEAR c.FEMALE#i.BIRTHCOHORT2 i.YEAR i.BIRTHCOHORT2 if BIRTHCOHORT >= 1950, a(MOMID) cluster(PNR) 

areg LNEARN BD DEPRANX SCHIZO   $BDcoef1 `zero' $BDcoef2 $Dcoef1 $Dcoef2 $Scoef1 $Scoef2 FEMALE c.FEMALE#i.YEAR c.FEMALE#i.BIRTHCOHORT2 i.YEAR i.BIRTHCOHORT2 if NOEARN == 0 & BIRTHCOHORT >= 1950, a(MOMID) cluster(PNR) 


areg NOEARN BD DEPR SCHIZO ANX  $BDcoef1 `zero' $BDcoef2 $Dcoef1 $Dcoef2 $Scoef1 $Scoef2 $Acoef1 $Acoef2 FEMALE c.FEMALE#i.YEAR c.FEMALE#i.BIRTHCOHORT i.YEAR  i.BIRTHCOHORT if BIRTHCOHORT >= 1950, a(MOMID) cluster(MOMID) 
	areg LNEARN BD DEPR SCHIZO ANX  $BDcoef1 `zero' $BDcoef2 $Mcoef1 $Mcoef2 FEMALE c.FEMALE#i.YEAR c.FEMALE#i.BIRTHCOHORT i.YEAR  i.BIRTHCOHORT if NOEARN == 0 & BIRTHCOHORT >= 1950, a(MOMID) cluster(MOMID) 
